package com.ruoyi.web.controller.traditionalBookingSettings;


import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SelfBookingSettings;
import com.ruoyi.system.service.ISelfBookingSettingsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 传统预订设置自助预订设置，用于配置用户通过小程序预订的相关规则Controller
 *
 * @author ruoyi
 * @date 2025-05-12
 */
@Api(tags="传统预订设置自助预订设置")
@RestController
@RequestMapping("/system/selfBookingSettings")
public class SelfBookingSettingsController extends BaseController
{
    @Autowired
    private ISelfBookingSettingsService selfBookingSettingsService;

    /**
     * 查询自助预订设置列表
     */
    @ApiOperation("查询自助预订设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(SelfBookingSettings selfBookingSettings)
    {
        startPage();
        List<SelfBookingSettings> list = selfBookingSettingsService.selectSelfBookingSettingsList(selfBookingSettings);
        return getDataTable(list);
    }

    /**
     * 导出自助预订设置列表
     */
    @ApiOperation("导出自助预订设置列表")
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "自助预订设置，用于配置用户通过小程序预订的相关规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,SelfBookingSettings selfBookingSettings)
    {
        List<SelfBookingSettings> list = selfBookingSettingsService.selectSelfBookingSettingsList(selfBookingSettings);
        ExcelUtil<SelfBookingSettings> util = new ExcelUtil<SelfBookingSettings>(SelfBookingSettings.class);
        util.exportExcel(response, list, "自助预订设置，用于配置用户通过小程序预订的相关规则数据");
    }

    /**
     * 获取自助预订设置详细信息
     */
    @ApiOperation("获取自助预订设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(selfBookingSettingsService.selectSelfBookingSettingsById(id));
    }

    /**
     * 新增自助预订设置
     */
    @ApiOperation("新增自助预订设置")
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "自助预订设置，用于配置用户通过小程序预订的相关规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SelfBookingSettings selfBookingSettings)
    {
        return toAjax(selfBookingSettingsService.insertSelfBookingSettings(selfBookingSettings));
    }

    /**
     * 修改自助预订设置
     */
    @ApiOperation("修改自助预订设置")
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "自助预订设置，用于配置用户通过小程序预订的相关规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SelfBookingSettings selfBookingSettings)
    {
        return toAjax(selfBookingSettingsService.updateSelfBookingSettings(selfBookingSettings));
    }

    /**
     * 删除自助预订设置信息
     */
    @ApiOperation("删除自助预订设置信息")
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "自助预订设置，用于配置用户通过小程序预订的相关规则", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(selfBookingSettingsService.deleteSelfBookingSettingsByIds(ids));
    }


    /**
     * 根据门店ID查询自助预订设置详情
     */
    @ApiOperation("根据门店ID查询自助预订设置详情")
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping("/detail/{storeId}")
    public AjaxResult getTableSettingsDetail(@PathVariable("storeId") Long storeId) {
        SelfBookingSettings selfBookingSettings = selfBookingSettingsService.selectByStoreId(storeId);
        return success(selfBookingSettings);
    }


}
